package com.cj.easypoi.controller;

import java.io.File;
import java.io.FileWriter;
import java.io.BufferedWriter;
import java.io.IOException;

public class AppendToFileExample
{
    public static void main( String[] args )
    {
        try{
            String data = "S2F35 W\n<L\n\t<U2 1>\n\t<L";
            String s="\t\t<L\n\t\t\t<U2 100>    \n\t\t\t<L\n\t\t\t\t<U2 100>   \n\t\t\t>\n\t\t>";

            data = data+"\n"+s;
            File file =new File("javaio-appendfile.txt");

            //if file doesnt exists, then create it
            if(!file.exists()){
                file.createNewFile();
            }

            //true = append file
            FileWriter fileWritter = new FileWriter(file.getName(),true);
            fileWritter.write(data);
            fileWritter.close();

            System.out.println("Done");

        }catch(IOException e){
            e.printStackTrace();
        }
    }
}